using System;
using System.Collections;
using System.Text;
using System.Threading;
using Oracle.ManagedDataAccess.Client;
using OracleInternal.Common;

namespace OracleInternal.NotificationServices
{
	internal class SupportClass
	{
		public class ThreadClass : IThreadRunnable
		{
			private Thread threadField;

			public Thread Instance
			{
				get
				{
					return threadField;
				}
				set
				{
					threadField = value;
				}
			}

			public string Name
			{
				get
				{
					return threadField.Name;
				}
				set
				{
					if (threadField.Name == null)
					{
						threadField.Name = value;
					}
				}
			}

			public bool IsAlive => threadField.IsAlive;

			public bool IsBackground
			{
				get
				{
					return threadField.IsBackground;
				}
				set
				{
					threadField.IsBackground = value;
				}
			}

			public ThreadClass()
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.ThreadClass, OracleTraceFuncName.ctor);
				}
				threadField = new Thread(new ThreadStart(Run));
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.ThreadClass, OracleTraceFuncName.ctor);
				}
			}

			public virtual void Run()
			{
			}

			public virtual void Start()
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.ThreadClass, OracleTraceFuncName.Start);
				}
				threadField.Start();
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.ThreadClass, OracleTraceFuncName.Start);
				}
			}

			public void Join()
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.ThreadClass, OracleTraceFuncName.Join);
				}
				threadField.Join();
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.ThreadClass, OracleTraceFuncName.Join);
				}
			}

			public static ThreadClass Current()
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.ThreadClass, OracleTraceFuncName.Current);
				}
				ThreadClass result = new ThreadClass
				{
					Instance = Thread.CurrentThread
				};
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.ThreadClass, OracleTraceFuncName.Current);
				}
				return result;
			}
		}

		public interface SetSupport : ICollection, IEnumerable, IList
		{
			new bool Add(object obj);

			bool AddAll(ICollection c);
		}

		public class CalendarManager
		{
			public const int YEAR = 1;

			public const int MONTH = 2;

			public const int DATE = 5;

			public const int HOUR = 10;

			public const int MINUTE = 12;

			public const int SECOND = 13;

			public const int MILLISECOND = 14;

			public const int DAY_OF_YEAR = 4;

			public const int DAY_OF_MONTH = 6;

			public const int DAY_OF_WEEK = 7;

			public const int HOUR_OF_DAY = 11;

			public const int AM_PM = 9;

			public const int AM = 0;

			public const int PM = 1;
		}

		public static byte[] ToByteArray(sbyte[] sbyteArray)
		{
			byte[] result = null;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToByteArray);
			}
			try
			{
				if (sbyteArray != null)
				{
					result = new byte[sbyteArray.Length];
					for (int i = 0; i < sbyteArray.Length; i++)
					{
						result[i] = (byte)sbyteArray[i];
					}
					return result;
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)270532608, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToByteArray, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToByteArray);
				}
			}
		}

		public static byte[] ToByteArray(string sourceString)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToByteArray);
			}
			try
			{
				return Encoding.UTF8.GetBytes(sourceString);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)270532608, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToByteArray, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToByteArray);
				}
			}
		}

		public static sbyte[] ToSByteArray(byte[] byteArray)
		{
			sbyte[] result = null;
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097408, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToSByteArray);
			}
			try
			{
				if (byteArray != null)
				{
					result = new sbyte[byteArray.Length];
					for (int i = 0; i < byteArray.Length; i++)
					{
						result[i] = (sbyte)byteArray[i];
					}
					return result;
				}
				return result;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Private, (OracleTraceTag)270532608, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToSByteArray, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, (OracleTraceTag)2097664, OracleTraceClassName.SupportClass, OracleTraceFuncName.ToSByteArray);
				}
			}
		}
	}
}
